<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        Function.prototype.myApply = function(thisArg,argsArr)
        {
          if(typeof this !="function")
          {
             throw TypeError("非函数调用");
          }

          if(!Array.isArray(argsArr))
          {
             throw TypeError("argsArr不是数组");
          }

          const fnArg = Symbol();
          thisArg[fnArg] = this;
          const result = thisArg[fnArg](...argsArr);
          return result;
        }

        function sum (a,b)
        {
             return a+b;
        }

        let obj = {
            name:"cq",
            age :"hhhh"
        }

        const result = sum.myApply(obj,[12,45]);
        console.log(result);

    </script>
</body>
</html>